--- @param extension Package
--- @param HY HY_Utility
--- @param U Utility
return function(extension, HY, U)
    local hy_x_toutetsu_yuma = General:new(extension, "hy_x_toutetsu_yuma", "x_k", 4, 8, General.Female)
    local devour_desire = fk.CreateSkill {
        name = "devour_desire",
    }
    devour_desire:addEffect(fk.Death, {
        anim_type = "offensive",
        can_trigger = function(self, event, target, player, data)
            return player:hasSkill(self) and target ~= player
        end,
        on_cost = Util.TrueFunc,
        on_use = function(self, event, target, player, data)
            local room = player.room
            if player:isWounded() then
                room:recover({
                    who = player,
                    num = 1,
                    recoverBy = player,
                    skillName = devour_desire.name,
                })
            end
            if #target:getCardIds("he") > 0 then
                room:moveCardTo(target:getCardIds("he"), Card.PlayerSpecial, player, fk.ReasonJustMove, devour_desire.name, "devour_desire", true, player)
            end
        end
    })
    local blood_curse = fk.CreateSkill {
        name = "blood_curse",
    }
    blood_curse:addEffect(fk.EventPhaseStart, {
        anim_type = "offensive",
        can_trigger = function(self, event, target, player, data)
            return player:hasSkill(blood_curse.name) and player == target and player.phase == Player.Discard and #table.filter(player.room.alive_players, function(t)
                return not t:isKongcheng() and not player:isProhibited(t, Fk:cloneCard("fire_attack"))
            end) > 0 and player:isWounded() and player:canUse(Fk:cloneCard("fire_attack"))
        end,
        on_cost = Util.TrueFunc,
        on_use = function(self, event, target, player, data)
            local room = player.room
            local targets = table.filter(player.room.alive_players, function(t)
                return not t:isKongcheng() and not player:isProhibited(t, Fk:cloneCard("fire_attack"))
            end)
            local count = player.maxHp - player.hp
            if count > 0 then
                local result = room:askToChoosePlayers(player, {
                    targets = targets,
                    min_num = 1,
                    max_num = count,
                    prompt = "blood_curse_prompt:::" .. tostring(count),
                    skill_name = blood_curse.name
                })
                if #result > 0 then
                    room:sortByAction(result)
                    for _, t in ipairs(result) do
                        if not t:isKongcheng() then
                            room:useCard({
                                from = player,
                                tos = { t },
                                card = Fk:cloneCard("fire_attack"),
                            })
                        end
                    end
                end
            end
        end
    })
    blood_curse:addEffect(fk.TurnEnd, {
        can_trigger = function(self, event, target, player, data)
            local room = player.room
            return player:hasSkill(blood_curse.name) and player == target and #room.logic:getEventsOfScope(GameEvent.Damage, 1, function(e)
                return e.data.from and e.data.from == player and e.data.to == player
            end, Player.HistoryGame) == 0 and (type(player:getMark("blood_curse-turn")) ~= "table" or #player:getMark("blood_curse-turn") == 0)
        end,
        on_cost = Util.TrueFunc,
        on_use = function(self, event, target, player, data)
            local room = player.room
            room:damage({
                from = player,
                to = player,
                damage = 1,
                damageType = fk.NormalDamage,
            })
        end,
    })
    blood_curse:addEffect(fk.DamageCaused, {
        can_refresh = function(self, event, target, player, data)
            return player.phase ~= Player.NotActive and data.from and data.from == player
        end,
        on_refresh = function(self, event, target, player, data)
            local room = player.room
            local marks = type(player:getMark("blood_curse-turn")) == "table" and player:getMark("blood_curse-turn") or {}
            table.insertIfNeed(marks, data.to.id)
            room:setPlayerMark(player, "blood_curse-turn", marks)
        end
    })
    blood_curse:addEffect("filter", {
        card_filter = function(self, card, player)
            return player:hasSkill(blood_curse.name) and card.trueName == "slash" and player.phase ~= player.NotActive
        end,
        view_as = function(self, player, card)
            local result = Fk:cloneCard("fire_attack")
            result:addSubcard(card)
            return result
        end
    })
    local blood_refine = fk.CreateSkill {
        name = "blood_refine",
    }
    blood_refine:addEffect(fk.RoundEnd, {
        anim_type = "drawcard",
        can_trigger = function(self, event, target, player, data)
            return player:hasSkill(self)
        end,
        on_cost = Util.TrueFunc,
        on_use = function(self, event, target, player, data)
            local room = player.room
            local choices = { "blood_refine_damage", "blood_refine_card", "blood_refine_maxHp" }
            local valid = table.clone(choices)
            if #player:getPile("devour_desire") <= 0 then
                table.removeOne(valid, "blood_refine_card")
            end
            local mark = table.map(player:getTableMark("blood_refine_mark"), function(id)
                return room:getPlayerById(id)
            end)
            room:sortByAction(mark)
            local targets = table.filter(mark, function(t)
                return t:isAlive()
            end)
            if #targets == 0 then
                table.removeOne(valid, "blood_refine_damage")
            end
            local result = room:askToChoice(player, {
                choices = valid,
                skill_name = blood_refine.name,
                prompt = "blood_refine_prompt",
                all_choices = choices
            })
            if result == "blood_refine_damage" then
                for _, t in ipairs(targets) do
                    room:damage({
                        from = player,
                        to = t,
                        damage = 1,
                        damageType = fk.NormalDamage,
                    })
                end
            elseif result == "blood_refine_card" then
                local cards = player:getPile("devour_desire")
                if #cards > 3 then
                    cards = room:askToCards(player, {
                        min_num = 3,
                        max_num = 3,
                        skill_name = blood_refine.name,
                        cancelable = false,
                        pattern = ".|.|.|devour_desire",
                        prompt = "blood_refine_card_prompt",
                        expand_pile = "devour_desire"
                    })
                end
                room:obtainCard(player, cards, true, fk.ReasonPrey, player, blood_refine.name)
            else
                room:drawCards(player, 2, blood_refine.name)
                room:changeMaxHp(player, -2)
            end
        end
    })
    blood_refine:addEffect(fk.Damaged, {
        can_refresh = function(self, event, target, player, data)
            return player:hasSkill(self, true) and data.from and data.to == player
        end,
        on_refresh = function(self, event, target, player, data)
            local mark = player:getTableMark("blood_refine_mark")
            table.insertIfNeed(mark, data.from.id)
            player.room:setPlayerMark(player, "blood_refine_mark", mark)
            player.room:setPlayerMark(player, "@&blood_refine_mark", table.map(mark, function(id)
                return player.room:getPlayerById(id).general
            end))
        end
    })
    blood_refine:addEffect(fk.Deathed, {
        can_refresh = function(self, event, target, player, data)
            return player:hasSkill(self, true) and table.contains(player:getTableMark("blood_refine_mark"), data.who.id)
        end,
        on_refresh = function(self, event, target, player, data)
            local mark = player:getTableMark("blood_refine_mark")
            table.removeOne(mark, data.who.id)
            player.room:setPlayerMark(player, "blood_refine_mark", mark)
            player.room:setPlayerMark(player, "@&blood_refine_mark", table.map(mark, function(id)
                return player.room:getPlayerById(id).general
            end))
        end
    })
    extension:loadSkillSkels { devour_desire, blood_curse, blood_refine }
    hy_x_toutetsu_yuma:addSkill("devour_desire")
    hy_x_toutetsu_yuma:addSkill("blood_curse")
    hy_x_toutetsu_yuma:addSkill("blood_refine")
    Fk:loadTranslationTable {
        ["hy_x_toutetsu_yuma"] = "饕餮尤魔",
        ["#hy_x_toutetsu_yuma"] = "血池地狱",
        ["illustrator:hy_x_toutetsu_yuma"] = "Sya烙",
        ["designer:hy_x_toutetsu_yuma"] = "黑曜人形",
        ["cv:hy_x_toutetsu_yuma"] = "",

        ["devour_desire"] = "噬欲",
        [":devour_desire"] = "其他角色死亡时，你回复1点体力，然后将其所有牌置于你的武将牌上。",

        ["blood_curse"] = "血咒",
        [":blood_curse"] = "你的【杀】于回合内视为【火攻】。弃牌阶段开始时，你视为对至多X名角色使用【火攻】（X为你已损失的体力值）。回合结束时，若你未对自己造成过伤害且本回合未造成过伤害，你对自己造成1点伤害。",
        ["blood_curse_prompt"] = "血咒：对至多%arg名角色使用【火攻】",

        ["blood_refine"] = "炼血",
        [":blood_refine"] = "每轮结束时，你选择一项：1. 对所有对你造成过伤害的角色造成1点伤害；2.获得你武将牌上三张（不足则改为所有）牌；3.减少2点体力上限并摸两张牌。",
        ["blood_refine_damage"] = "造成伤害",
        ["blood_refine_card"] = "获得牌",
        ["blood_refine_maxHp"] = "减少上限",
        ["blood_refine_prompt"] = "炼血：你须选择一项",
        ["blood_refine_card_prompt"] = "炼血：获得武将牌上三张牌",
        ["@&blood_refine_mark"] = "炼血",
    }
end
